<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
</head>
<body>
    <script>
        //这样会形成一个递归
        /* let persion = {};
        Object.defineProperty(persion,name,{
            set(value){ //当给person.name赋值时就会调用该方法
                console.log(value);
                this.name = value;
            },
            get(){ //当获取person.name时调用该方法
                return 100
            }
        }); */

        //模拟数据代理
        let _data = {msg:'iwat'};
        let vm = {};
        Object.defineProperty(vm,data,{
            set(value){
                _data.msg = value;
            },
            get(){
                return _data.msg;
            }
        });
    </script>
</body>
</html>